
<div class="list_heading"><h2><?php echo "Search By " . $keyword; ?></h2></div>
<?php if(isset($show_add)) { ?>
	<!--<div>
		<?php //echo $category->ad_rectangle_hr_medium; ?>
	</div>-->
<?php } ?>

<?php if(isset($pagination)) echo  '<div class="topPagination">'.$pagination.'</div>'; ?>
<div class="product_list_block">
	<?php
	if ($products->num_rows() > 0)
	{
		$show_ad_after = $products->num_rows / 2;
		$show_ad_after = $show_ad_after < 2 ? -1 : $show_ad_after;
		$i = 0;
		$count_column = 0;
		foreach ($products->result() as $row)
		{
			++$count_column;
			$i = $i + 1; 
			$product_link = get_product_url($row);
	?>
			<div id="<?php echo 'product-', $row->product_id; ?>" class="product <?php switch($count_column){case 1: echo 'firstColumn'; break; case 2: echo 'midColumn'; break; case 3: echo 'lastColumn'; break;} ?>" title="<?php echo $row->product_title; ?>">
				<div class="productBoxShadow"></div>
				<?php $shortTitle = substr($row->product_title, 0, 24); ?>
				<h2 class="title"><?php echo '<a rel="bookmark" href="', $product_link, '">', $shortTitle,' ...', '</a>'; ?></h2> 
				<span class="author">  <?php //echo '|', $row->author_name; ?></span>
				<div class="productImage">
					
					<?php if(empty($row->aff_img_medium)){ ?>
						<a href="<?php echo $product_link; ?>"><img src="<?php echo $this->config->config['public_url'].'/images/img-default.png'; ?>" alt="No image exists" width="198" height="167" /></a>
					<?php } else{ ?>
						<a href="<?php echo $product_link; ?>"><img src="<?php echo $row->aff_img_medium; ?>" alt="" /></a>
					<?php } ?>
				</div>
				<?php
				/*
				<div class="entry">
					<p>	
						<?php 
							$first_paragraph_end = strpos($row->product_desc, "</p>"); 
							$first_paragraph_end = $first_paragraph_end > 1000 ? 1000 : $first_paragraph_end;
							$first_paragraph_end = $first_paragraph_end == 0 ? 1000 : $first_paragraph_end;
							echo strip_tags(substr($row->product_desc, 0, $first_paragraph_end)); 
						?> 
						<a class="more-link" href="<?php echo $product_link; ?>">Read complete product</a>
					</p>
				</div>
				*/
				?>
				<div class="boxMeta">
					<span class="p-cost">$<?php echo $row->sale_price; ?> </span>
					<a class="p-link" href="<?php echo $product_link; ?>">Details</a>
					<div class="cb"></div>
				</div>
			</div>
			<?php if(isset($show_add) && $show_ad_after == $i) { ?>
			<div>
				<?php // echo $category->ad_rectangle_hr_medium; ?>
			</div>
			<?php } ?>
	<?php
			if($count_column == 3){
				$count_column = 0;
				echo '<div class="cb"></div>';
			}
		}
	}else{ echo '<div class="noResult">Sorry, no result(s) found</div>';}
	?>
</div>
<?php if(isset($pagination)) echo  '<div class="bottomPagination">'.$pagination.'</div>'; ?>
<script type="text/javascript">
	//<![CDATA[
	
		jQuery(document).ready(function(){

			//Red shadow appears behind product box on hover
			jQuery('.main .content .product').hover(function(){
				jQuery(this).children('.productBoxShadow').stop().animate({'opacity':1});
			},function(){
				jQuery(this).children('.productBoxShadow').stop().animate({'opacity':0});
			});
		});
		
		jQuery(window).load(function(){
			//Image padding to make equal size of product box
			var biggestHeight = 0;
			//determine biggest image height
			jQuery('.product .productImage').each(function(){
				if(jQuery(this).height() > biggestHeight){
					biggestHeight = jQuery(this).height();
				}
			});
			var currentHeight = 0;
			//create equal size of image
			jQuery('.product .productImage').each(function(){
				currentHeight = jQuery(this).height();
				if(biggestHeight > currentHeight){
					jQuery(this).css('padding-top', biggestHeight - currentHeight + 'px');
				}
			});
			
			
			//Script to generate title of product in tooltip.
			//initiate tooltip script
			jQuery('.product_list_block div.product[title]').tooltip({effect: 'fade', width: '150px'});		
			//create fade effect on tooltip
			jQuery('.product_list_block div.product').hover(function(){
				jQuery('#tooltip').css('opacity',0);
					jQuery('#tooltip').animate({'opacity':1});
				},function(){
					jQuery('#tooltip').css('opacity',0);
			});
		});
		
	//]]>
</script>
<?php if(isset($show_add)) { ?>
	<!--<div>
		<?php  echo $category->ad_rectangle_hr_medium; ?>
	</div>-->
<?php } ?>
